package com.local.goods.feign;

import com.local.common.util.ResultUtil;
import com.local.goods.pojo.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("goodsservice")
public interface GoodsServiceFeign {


    /**
     * 通过id查询商品分类数据
     * @param categoryId
     * @return
     */
    @GetMapping("/category/{id}")
    @ResponseBody
    public ResultUtil<GoodsCategory> getCategoryById(@PathVariable("id") Integer categoryId);

    /**
     * 查询商品分类列表数据，支持翻页(用于后台)
     * @param requestParam
     * @return
     */
    @GetMapping("/category/list")
    @ResponseBody
    public ResultUtil categoryList(@RequestBody GoodsCategoryListRequestParam requestParam);


    /**
     * 新增(用于后台)
     * @param goodsCategory
     * @return
     */
    @PostMapping("/category/save")
    @ResponseBody
    public ResultUtil categorySave(@RequestBody GoodsCategory goodsCategory);


    /**
     * 修改(用于后台)
     * @param goodsCategory
     * @return
     */
    @PostMapping("/category/update")
    @ResponseBody
    public ResultUtil categoryUpdate(@RequestBody GoodsCategory goodsCategory);


    /**
     * 批量删除。用于后台
     * @param requestParam
     * @return
     */
    @PostMapping("/category/delete")
    @ResponseBody
    public ResultUtil categoryDelete(@RequestBody GoodsCategoryDeleteRequestParam requestParam);

    /**
     * 通过parent id选择下级分类列表(用于后台)
     * @param categoryId
     * @return
     */
    @GetMapping("/category/listForSelect")
    @ResponseBody
    public ResultUtil categoryListForSelect(@RequestParam("categoryId") Integer categoryId);

    /**
     * 商品分类数据（用于网站首页）
     * @return
     */
    @GetMapping("/category/list/index")
    @ResponseBody
    public ResultUtil<List<GoodsCategory>> getIndexCategoryList();


    /**
     * 通过id查询商品
     * @param id
     * @return
     */
    @GetMapping("/goods/{id}")
    @ResponseBody
    public ResultUtil<Goods> getGoodsById(@PathVariable("id") Integer id);


    /**
     * 查询商品列表，支持翻页（后台管理）
     * @param requestParam
     * @return
     */
    @GetMapping("/goods/list")
    @ResponseBody
    public ResultUtil goodsList(@RequestBody GoodsListRequestParam requestParam);


    /**
     * 新增商品（后台管理）
     * @param goods
     * @return
     */
    @PostMapping("/goods/save")
    @ResponseBody
    public ResultUtil goodsSave(@RequestBody Goods goods);


    /**
     * 修改。注意：商品下架的时候，要检查商品是否在首页的推荐栏目中（后台管理）
     * @param goods
     * @return
     */
    @PostMapping("/goods/update")
    @ResponseBody
    public ResultUtil goodsUpdate(@RequestBody Goods goods);


    /**
     * 商品的上架和下架（后台管理）
     * @param requestParam
     * @return
     */
    @PutMapping("/goods/status")
    @ResponseBody
    public ResultUtil goodsStatus(@RequestBody GoodsStatusRequestParam requestParam);


    /**
     * 通过id查询商品，不包括“商品详情”字段
     * @param id
     * @return
     */
    @GetMapping("/goods/simple/{id}")
    @ResponseBody
    public ResultUtil<Goods> getSimpleById(@PathVariable("id") Integer id);


    /**
     * 通过ids批量查询商品列表
     * @param ids
     * @return
     */
    @GetMapping("/goods/listByIds")
    @ResponseBody
    public ResultUtil<List<Goods>> getGoodsListByIds(@RequestBody List<Integer> ids);

    /**
     * 批量更新商品库存
     * @param goodsStockNumList
     * @return
     */
    @PostMapping("/goods/updateGoodsStockNum")
    @ResponseBody
    public ResultUtil<String> updateGoodsStockNum(@RequestBody List<Goods> goodsStockNumList);


    /**
     * 使用elasticsearch，按关键词keywords，对goods进行搜索
     * @param param
     * @return
     */
    @GetMapping("/goods/search")
    @ResponseBody
    public ResultUtil search(@RequestBody GoodsESRequestParam param);


    /**
     * 搜索的自动补齐，即搜索建议
     * @param keywords
     * @return
     */
    @PostMapping("/goods/searchSuggestion")
    @ResponseBody
    public ResultUtil<List<String>> searchSuggestion(@RequestBody String keywords);
}
